#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time   : 2023/6/3
# @Author : Renee

import configparser
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import IEDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager

config = configparser.ConfigParser()
config.read("config.ini", encoding="utf-8")


def get_browser_engine():
    browser = config.get('browserType', 'browserName')
    if browser == 'Firefox' or browser == 'firefox' or browser == '火狐':
        browser_driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
        return browser_driver
    elif browser == 'Ie' or browser == 'ie':
        browser_driver = webdriver.Ie(IEDriverManager().install())
        return browser_driver
    elif browser == 'Edge':
        browser_driver = webdriver.Edge(EdgeChromiumDriverManager().install())
        return browser_driver
    elif browser == 'Chrome' or browser == 'chrome' or browser == '谷歌':
        # 隐藏浏览器界面
        # chrome_option = Options()
        # chrome_option.add_argument('--headless')
        # chrome_option.add_argument('--disable-gpu')
        # driver = webdriver.Chrome(options=chrome_option)
        # 自动下载浏览器对应版本的驱动
        # driver = webdriver.Chrome(ChromeDriverManager().install())
        browser_driver = webdriver.Chrome()
        # print(dir(browser_driver))
        return browser_driver
    else:
        print("请输入正确的浏览器")





def get_url():
    url = config.get("testServer", "url")
    return url


def get_send_user_list():
    send_user_list = config.get("email", "send_user_list")
    return send_user_list


def get_addressee_list():
    addressee_list = config.get("email", "addressee_list")
    return addressee_list


def get_tester_name():
    tester_name = config.get("tester", "tester_name")
    return tester_name


def get_lark_webhook():
    webhook = config.get("lark", "webhook")
    return webhook
